package com.blog.wl2023.controller.admin;

import com.blog.wl2023.entity.response.PageResult;
import com.blog.wl2023.entity.response.Result;
import com.blog.wl2023.service.admin.ManageService;
import com.blog.wl2023.utils.note.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author wule
 * @desc 后台系统的接口
 */
@RestController
@RequestMapping("api/admin/manage")
@ResponseResult
@Slf4j
public class AdminManageController {

	@Autowired
	ManageService manageService;

	/**
	 * 获取文章集合数据填充到表格数据
	 *
	 * @param pageNo   当前页码
	 * @param pageSize 页面尺寸
	 * @param title    搜索参数 -> 标题
	 * @param typeId   搜索参数 -> 类型
	 * @param isTop    搜索参数 -> 是否置顶
	 * @param isDelete 搜索参数 -> 是否删除
	 * @param summary  搜索参数 -> 概述
	 * @return PageResult
	 */
	@GetMapping("manageGetArticles/{pageNo}/{pageSize}")
	public PageResult manageGetArticles(@PathVariable int pageNo,
	                                    @PathVariable int pageSize,
	                                    @RequestParam(required = false) String title,
	                                    @RequestParam(required = false) String typeId,
	                                    @RequestParam(required = false) String isTop,
	                                    @RequestParam(required = false) String isDelete,
	                                    @RequestParam(required = false) String summary
	) {
		log.info("<manage-Articles>当前页码:{},页面尺寸:{},模糊搜索参数:{},{},{},{},{}", pageNo, pageSize, title, typeId, isTop, isDelete, summary);
		return manageService.manageGetArticles(pageNo, pageSize, title, typeId, isTop, isDelete, summary);
	}


	/**
	 * 获取随想集合数据填充到表格数据
	 *
	 * @param pageNo         当前页码
	 * @param pageSize       页面尺寸
	 * @param capriceContent 搜索参数 -> 内容
	 * @param isDelete       搜索参数 -> 是否删除
	 * @return PageResult
	 */
	@GetMapping("manageGetCaprices/{pageNo}/{pageSize}")
	public PageResult manageGetCaprices(@PathVariable int pageNo,
	                                    @PathVariable int pageSize,
	                                    @RequestParam(required = false) String capriceContent,
	                                    @RequestParam(required = false) String isDelete
	) {
		log.info("<manage-Caprices>当前页码:{},页面尺寸:{},模糊搜索参数:{},{}", pageNo, pageSize, capriceContent, isDelete);
		return manageService.manageGetCaprices(pageNo, pageSize, capriceContent, isDelete);
	}


	/**
	 * 获取类型集合数据填充到表格数据
	 *
	 * @param pageNo   当前页码
	 * @param pageSize 页面尺寸
	 * @return PageResult
	 */
	@GetMapping("manageGetTypes/{pageNo}/{pageSize}")
	public PageResult manageGetTypes(@PathVariable int pageNo,
	                                 @PathVariable int pageSize) {
		log.info("<manage-Types>当前页码:{},页面尺寸:{}", pageNo, pageSize);
		return manageService.manageGetTypes(pageNo, pageSize);
	}


	/**
	 * 根据文章的uuid查询所有评论
	 *
	 * @param pageNo    当前页码
	 * @param pageSize  页面尺寸
	 * @param articleId 文章uuid
	 * @return PageResult
	 */
	@GetMapping("manageGetCommentsByUuid/{pageNo}/{pageSize}")
	public PageResult manageGetCommentsByUuid(@PathVariable int pageNo,
	                                          @PathVariable int pageSize,
	                                          @RequestParam String articleId) {
		log.info("<manage-articleComment>当前页码:{},页面尺寸:{},文章id:{}", pageNo, pageSize, articleId);
		return manageService.manageGetCommentsByUuid(pageNo, pageSize, articleId);
	}


	/**
	 * 获取所有百宝箱页面的链接信息
	 * @param pageNo    当前页码
	 * @param pageSize  页面尺寸
	 * @param urlName 网站名称
	 * @param description 网站描述
	 * @param typeId 网站类型
	 * @return PageResult
	 */
	@GetMapping("manageAllTreasureChests/{pageNo}/{pageSize}")
	public PageResult manageAllTreasureChests(@PathVariable int pageNo,
	                                    @PathVariable int pageSize,
	                                    @RequestParam(required = false) String urlName,
	                                    @RequestParam(required = false) String description,
	                                    @RequestParam(required = false) String typeId
	){
		log.info("<manage-treasureChests>当前页码:{},页面尺寸:{},模糊搜索参数:{},{},{}", pageNo, pageSize, urlName, description, typeId);
		return manageService.manageAllTreasureChests(pageNo, pageSize, urlName, description, typeId);
	}


	/**
	 * 获取所有留言板留言
	 * @param pageNo    当前页码
	 * @param pageSize  页面尺寸
	 * @param messageContent 消息体
	 * @param isDelete 是否显示
	 * @param starTime 开始时间
	 * @param endTime 结束时间
	 * @return
	 */
	@GetMapping("manageGetMessageLists/{pageNo}/{pageSize}")
	public PageResult manageGetMessageLists(@PathVariable int pageNo,
	                                    @PathVariable int pageSize,
	                                    @RequestParam(required = false) String messageContent,
	                                    @RequestParam(required = false) String isDelete,
	                                    @RequestParam(required = false) String starTime,
	                                    @RequestParam(required = false) String endTime

	){
		log.info("<manage-messageList>当前页码:{},页面尺寸:{},模糊搜索参数:{},{},{},{}", pageNo, pageSize, messageContent, isDelete, starTime,endTime);
		return manageService.manageGetMessageLists(pageNo, pageSize, messageContent, isDelete, starTime,endTime);
	}

	@GetMapping("manageGetUsers/{pageNo}/{pageSize}")
	public PageResult manageGetUsers(@PathVariable int pageNo,
	                                    @PathVariable int pageSize,
	                                    @RequestParam(required = false) String username,
	                                    @RequestParam(required = false) String email,
	                                    @RequestParam(required = false) String status

	){
		log.info("<manage-user>当前页码:{},页面尺寸:{},模糊搜索参数:{},{},{}", pageNo, pageSize, username, email, status);
		return manageService.manageGetUsers(pageNo, pageSize, username, email, status);
	}




	/**
	 * 获取当前所有公告的信息
	 * @return Result
	 */
	@GetMapping("manageGetAnnouncement")
	public Result manageGetAnnouncement() {
		return manageService.manageGetAnnouncement();
	}

	/**
	 * 获取所有待审核的友链信息(即isDelete为1的)
	 * @return Result
	 */
	@GetMapping("manageGetTreasureChestsByIsDelete")
	public Result manageGetTreasureChestsByIsDelete() {
		return manageService.manageGetTreasureChestsByIsDelete();
	}






}
